import 'package:flutter/material.dart';

class UserModel {
  final int parentId;
  final int myId;

  UserModel(this.parentId, this.myId);
}

class UserWidget extends InheritedWidget {
  final UserModel userModel;

  UserWidget({
    Key key,
    @required this.userModel,
    @required Widget child,
  }) : super(key: key, child: child);

  static UserWidget of(BuildContext context) {
    //提供数据模型方法
    return context.inheritFromWidgetOfExactType(UserWidget);
  }

  @override
  bool updateShouldNotify(UserWidget oldWidget) {
    return userModel.parentId != oldWidget.userModel.parentId;
  }
}
